<script>
	export default {
		globalData: {
			websiteUrl: 'https://mhapp.tqapi.com',
			websiteKey: 'QQ1660875559', //后台APP密钥
			facility: 'Android', //系统 Android 、ios
			deviceid: '', //系统 id
			img_websiteUrl: '',
			uid: '',
			utoken: '',
			webUrl: 'https://mhapp.tqapi.com',
			book_img: '',
			sigmob: 1849548002,
			version: ''
		},
		onLaunch: function() {
			console.log('App Launch')
		},
		onShow: function() {
			this.init()
			console.log('App Show')
			var args= plus.runtime.arguments;  
			if(args){  
				console.log(args)
			    // 处理args参数，如直达到某新页面等  
			}  
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods: {
			init(){
				var _this = this;
				// #ifdef H5
				console.log("h5")
				getApp().globalData.deviceid = uni.$u.guid(10)
				console.log(getApp().globalData.deviceid)
				// #endif
				// #ifndef H5
				console.log("非h5")
				uni.getSystemInfo({
					success: function(res) {
						getApp().globalData.facility = res.platform //ios  or android
						console.log('手机系统信息', getApp().globalData.facility);
					}
				});
				if(getApp().globalData.facility=='ios'){
					plus.device.getInfo({
						success: function(e) {
							getApp().globalData.deviceid = e.uuid;
							console.log(getApp().globalData.deviceid)
						},
						fail: function(e) {
							console.log(e);
						}
					});
				}else{
					getApp().globalData.facility = "android"
					plus.device.getAAID({
						success: function(e) {
							getApp().globalData.deviceid = e.aaid;
							if(getApp().globalData.deviceid==''){
								// getApp().globalData.deviceid = "asawsdqwefwsnjfiowehnfjuoweisfnuj"
								getApp().globalData.deviceid = uni.$u.guid(10)
							}
							console.log(getApp().globalData.deviceid);
						},
						fail: function(e) {
							console.log(e);
							plus.device.getInfo({
								success: (res) => {
									getApp().globalData.deviceid = res.uuid.split(',')[0];
									console.log(getApp().globalData.deviceid);
								},
								fail:function(res){
									plus.device.getOAID({
										success:function(r){
											getApp().globalData.deviceid = r.oaid;
											console.log('getOAID success: '+JSON.stringify(r));
										},
										fail:function(r){
											console.log('getOAID failed: '+JSON.stringify(r));
										}
									});
									
									
								}
							})
						}
					});
				}
				// #endif
			}
		}
	}
</script>

<style lang="scss">
	/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
	@import "@/uni_modules/uview-ui/index.scss";
	
	@font-face {
		  font-family: 'iconfont' ;  /* project id 1997429 */
		  src: url('https://at.alicdn.com/t/font_1997429_8xzvctxta3u.eot');
		  src: url('https://at.alicdn.com/t/font_1997429_8xzvctxta3u.eot?#iefix') format('embedded-opentype'),
		  url('https://at.alicdn.com/t/font_1997429_8xzvctxta3u.woff2') format('woff2'),
		  url('https://at.alicdn.com/t/font_1997429_8xzvctxta3u.woff') format('woff'),
		  url('https://at.alicdn.com/t/font_1997429_8xzvctxta3u.ttf') format('truetype'),
		  url('https://at.alicdn.com/t/font_1997429_8xzvctxta3u.svg#iconfont') format('svg');
	}
	.iconfont{
	    font-family:"iconfont" !important;
		font-style:normal;
	    -webkit-font-smoothing: antialiased;
	    -webkit-text-stroke-width: 0.2px;
	    -moz-osx-font-smoothing: grayscale;
	}
</style>
